package com.example.mpgen.controller;

import com.example.mpgen.repository.DBSourceRepository;
import com.example.mpgen.repository.TemplateRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author admin
 * @version 1.0.0
 * @ClassName PageController.java
 * @Description TODO
 * @createTime 2022年09月27日 15:44:00
 */
@Controller
public class PageController {

    @Autowired
    private DBSourceRepository dbSourceRepository;

    @Autowired
    private TemplateRepository templateRepository;
    @RequestMapping("/main")
    public String main() {
        return "main";
    }

    @RequestMapping("/dbsource")
    public String dbsource(Model model) {
        model.addAttribute("dslist", dbSourceRepository.findAll());
        return "dbsource";
    }

    @RequestMapping("/template")
    public String template(Model model) {
        model.addAttribute("dslist", dbSourceRepository.findAll());
        model.addAttribute("templates", templateRepository.findAll());
        return "template";
    }

}
